package org.zjt.reflect;

import java.lang.reflect.Method;

/**
 * @author juntao.zhang
 * @version V1.0
 * @Description: TODO
 * @Package org.zjt.reflect
 * @date 2018/11/3 19:51
 */
public class Reflection {

    public static void main(String[] args) throws Exception {
        Method sum = Reflection.class.getDeclaredMethod("sum", int[].class);

        for (int i = 0; i < 200; i++) {
            Object invoke = sum.invoke(Reflection.class, new int[]{1, 2, 2, 3, 4, 4});
            System.out.println(invoke);
        }
    }

    public static int sum(int[] args) {
        int num = 0;
        for (int arg : args) {
            num += arg;
        }
        new RuntimeException().printStackTrace();
        return num;
    }
}
